﻿// Decompiled with JetBrains decompiler
// Type: Bannerlord.ModuleManager.ApplicationVersionComparer
// Assembly: MCMv5, Version=5.10.2.0, Culture=neutral, PublicKeyToken=null
// MVID: 7AB326B9-B2B4-41C2-9177-68E944071101
// Assembly location: D:\steam\steamapps\workshop\content\261550\2859238197\bin\Win64_Shipping_Client\MCMv5.dll

using System.Collections;
using System.Collections.Generic;

#nullable enable
namespace Bannerlord.ModuleManager
{
  internal class ApplicationVersionComparer : IComparer<ApplicationVersion?>, IComparer
  {
    public int Compare(object? x, object? y)
    {
      return this.Compare(x as ApplicationVersion, y as ApplicationVersion);
    }

    public virtual int Compare(ApplicationVersion? x, ApplicationVersion? y)
    {
      return ApplicationVersionComparer.CompareStandard(x, y);
    }

    public static int CompareStandard(ApplicationVersion? x, ApplicationVersion? y)
    {
      if ((object) x == null && (object) y == null)
        return 0;
      if ((object) x == null)
        return -1;
      if ((object) y == null)
        return 1;
      int num1 = x.ApplicationVersionType.CompareTo((object) y.ApplicationVersionType);
      if (num1 != 0)
        return num1;
      int num2 = x.Major;
      int num3 = num2.CompareTo(y.Major);
      if (num3 != 0)
        return num3;
      num2 = x.Minor;
      int num4 = num2.CompareTo(y.Minor);
      if (num4 != 0)
        return num4;
      num2 = x.Revision;
      int num5 = num2.CompareTo(y.Revision);
      if (num5 != 0)
        return num5;
      num2 = x.ChangeSet;
      int num6 = num2.CompareTo(y.ChangeSet);
      return num6 != 0 ? num6 : 0;
    }
  }
}
